package co.yixiang.modules.member.serviceimpl;

import co.yixiang.common.service.BaseService;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.utils.QueryHelpPlus;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.modules.member.entity.domain.YxUser;
import co.yixiang.modules.member.entity.domain.YxUserIntegralDetail;
import co.yixiang.modules.member.entity.dto.YxUserDto;
import co.yixiang.modules.member.entity.dto.YxUserIntegralDetailQueryCriteria;
import co.yixiang.modules.member.mapper.UserIntegralDetailMapper;
import co.yixiang.modules.member.service.YxUserIntegralDetailService;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxUserIntegralDetailServiceImpl extends BaseServiceImpl<UserIntegralDetailMapper, YxUserIntegralDetail> implements YxUserIntegralDetailService {
    @Autowired
    private IGenerator generator;

    @Override
    public Map<String, Object> queryAll(YxUserIntegralDetailQueryCriteria criteria, Pageable pageable) {
        getPage(pageable);
        PageInfo<YxUserIntegralDetail> page = new PageInfo<>(queryAll(criteria));
        Map<String, Object> map = new LinkedHashMap<>(2);
        map.put("content", page.getList());
        map.put("totalElements", page.getTotal());
        return map;
    }

    @Override
    public List<YxUserIntegralDetail> queryAll(YxUserIntegralDetailQueryCriteria criteria) {
        return baseMapper.selectList(QueryHelpPlus.getPredicate(YxUserIntegralDetail.class, criteria));
    }
}
